using System.Threading.Tasks;
using Admin.NET.Application.Entity.Business;
using Admin.NET.Application.Service.ApiJob.Dto;
using Admin.NET.Core;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;

namespace Admin.NET.Application.Service.ApiJob;

[ApiDescriptionSettings(new string[] { "业务应用" }, Order = 100)]
public class ApiJobDetialService : IDynamicApiController, ITransient, IPrivateDependency
{
	private readonly SqlSugarRepository<ApiJobDetial> _repJob;

	public ApiJobDetialService(SqlSugarRepository<ApiJobDetial> repJob)
	{
		_repJob = repJob;
	}

	/// <summary>
	/// 获取作业执行详情
	/// </summary>
	/// <param name="input"></param>
	/// <returns></returns>
	[HttpGet("/job/apijobdetial/page")]
	public async Task<dynamic> Page([FromQuery] JobDetialQuaryInput input)
	{
		ISugarQueryable<ApiJobDetial> query = from u in _repJob.AsQueryable()
			where u.ApiJobId == input.JobId
			select u;
		query = query.OrderBuilder(input);
		return await query.ToPagedListAsync(input.Page, input.PageSize);
	}
}
